package com.hao.servlet;
import com.hao.entity.product;
import com.hao.service.productservice;
import com.hao.serviceImpl.productserviceImpl;

import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;



/**
 * Created by Administrator on 2018/7/31.
 */
public class Servletadd extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();

        product oo=new product();
        oo.setEnumber(request.getParameter("enumber"));
        oo.setManufactureTime(request.getParameter("manufactureTime"));
        oo.setUserid(Integer.parseInt(request.getParameter("userid")));
        oo.setWpid(Integer.parseInt(request.getParameter("wpid")));
        oo.setInstall(Integer.parseInt(request.getParameter("install")));
        oo.setAllocationDate(request.getParameter("allocationDate"));
        productservice bb=new productserviceImpl();

        int i=bb.add(oo);


        if(i>0){

            out.print("<script language='javascript'>history.go(-1);</script>");
        }else{
            out.print("<script language='javascript'>history.go(-1);alert('新增失败');</script>");
        }
        out.flush();
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
    }
}
